#pragma once
#include"Hash.h"

template<class K,class V,class Hash=HashFunc<K>>
class unordered_Map
{
	struct MapofK
	{
		const K& operator()(const pair<K, V>& data)
		{
			return data.first;
		}
	};
public:
	typedef typename hash_bucket::HashTable<K, pair<const K, V>, MapofK, Hash>::iterator iterator;
	typedef typename hash_bucket::HashTable<K, pair<const K, V>, MapofK, Hash>::const_iterator const_iterator;


	iterator begin()
	{
		return _ht.begin();
	}

	iterator end()
	{
		return _ht.end();
	}

	const_iterator begin() const
	{
		return _ht.begin();
	}

	const_iterator end() const
	{
		return _ht.end();
	}

	pair<iterator, bool> insert( const pair<K,V>& data)
	{
		return _ht.insert(data);
	}

	V& operator[](const K& key)
	{
		pair<iterator, bool> ret = _ht.insert(make_pair(key, V()));

		return ret.first->second;
	}

	iterator Find(const K& key)
	{
		return _ht.find(key);
	}

	bool Erase(const K& key)
	{
		return _ht.erase(key);
	}
private:
	hash_bucket::HashTable<K,  pair<const K, V>, MapofK, Hash> _ht;
};